package demo_base.rmi;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

public class Client {
    public static void main(String[] args) {
        try {
            Hello hello = (Hello) Naming.lookup("//127.0.0.1:8080/wbh");//获取远程对象
            // 执行内容，sayHello方法的内容在服务器端执行，而sayHello的返回值在客户端取得
            System.out.println(hello.sayHello(new User("james")));
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (NotBoundException e) {
            e.printStackTrace();
        }
    }
}